package com.alibaba.cloud.medicine.service.impl;

import com.alibaba.cloud.medicine.dao.MedSheetMapper;
import com.alibaba.cloud.medicine.entity.MedSheet;
import com.alibaba.cloud.medicine.service.MedSheetService;
import com.alibaba.framework.exception.BusinessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
public class MedSheetServiceImpl implements MedSheetService {

    @Autowired
    private MedSheetMapper medSheetMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int add(MedSheet medSheet) {

        medSheet.setCreateTime(new Date());
        int i = medSheetMapper.insert(medSheet);
        if (i<0) {
            throw new BusinessException("保存药品申请表失败！");
        }
        return i;
    }
}
